<template>
    <div class="sign-container">
        <!-- <div>仪器信息网</div> -->
        <div class="login-nav" v-if="routerQueryType != 'teacher'">
      <div class="nav-content">
        <div class="l-logo">
          <a href="https://www.instrument.com.cn" target="_blank">
            <img src="https://img1.17img.cn/ui/simg/instrument/20220330/yxt_logo_20220721.png" alt="">
            <span>3i讲堂</span>
          </a>
          <!-- <a href="https://www.instrument.com.cn/list/yxt.html" target="_blank">
            <img src="https://img1.17img.cn/ui/simg/instrument/20220330/yxt_toplefthelp_20220721.png" alt="">
          </a> -->
        </div>

      </div>
    </div>
        <div class="sign-box">
            <div class="sign-bg">
                <p class="sign-bg-title">成为3i讲堂讲师</p>
                <p class="sign-bg-begin"></p>

                <p class="sign-bg-t-gary" style="line-height: 34px;">与1万位行业大咖一起<br>以专业会议推动科学仪器行业快速发展</p>

                <!-- <img src="https://img1.17img.cn/ui/simg/instrument/20220308/yxt_GIF_8M_20220704.gif" alt=""> -->
                <img src="https://img1.17img.cn/ui/simg/instrument/20230302/yht/img/tuxing_20230202.png" alt="" />
            </div>
            <div class="sign-form">
                <div class="title">填写申请信息</div>
                <div class="ms">工作人员会在72小时内与您沟通需求，请保持电话通畅</div>
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="125px" class="demo-ruleForm">
                    <el-form-item label="姓名" prop="name">
                        <el-input v-model="ruleForm.name" placeholder="请输入姓名" class="input-code"></el-input>
                    </el-form-item>
                    <el-form-item label="手机号" prop="mobile">
                        <el-input v-model="ruleForm.mobile" maxlength="11" placeholder="请输入手机号"
                            class="input-code"></el-input>
                    </el-form-item>
                    <el-form-item label="单位" prop="jobaddress">
                        <el-input v-model="ruleForm.jobaddress" placeholder="请输入单位" class="input-code"></el-input>
                    </el-form-item>
                    <el-form-item label="职位" prop="job">
                        <el-input v-model="ruleForm.job" placeholder="请输入职位" class="input-code"></el-input>
                    </el-form-item>
                    <el-form-item label="熟悉行业" prop="industry">
                        <el-cascader v-if="showvideo" v-model="DomainClassification" ref="areaCascader2" style="width: 373px;" class="input-code"
                            :props="props2" @change="changeImIndustry" />
                    </el-form-item>
                    <el-form-item label="熟悉仪器" prop="instrument">
                        <el-cascader v-if="showvideo" ref="areaCascader" style="width: 373px;" v-model="ProductClassification" class="input-code"
                            :props="CPprops" @change="changeImmsort" />
                    </el-form-item>
                    <el-form-item label="推荐人" prop="inviter">
                        <el-input v-model="ruleForm.inviter" placeholder="请输入推荐人" class="input-code"></el-input>
                    </el-form-item>
                    <el-form-item label="发表的内容文章" prop="abstr">
                        <el-input type="textarea" v-model="ruleForm.abstr" placeholder="请输入发表的内容文章"
                            class="input-code"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')" class="teache-butn">立即提交</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>
<script>
import api from "@/api";
import axios from "axios";
import "vue-country-intl/lib/vue-country-intl.css";
import { checkLoginPhone, debounce } from "@/utils/validate";
const validateMobile = function (rule, value, callback) {
    let newValue = value.replace(/[^0-9]/gi, '')
    if (value !== newValue) {
        callback(new Error('请输入正确的手机号'))
    } else if (newValue.length !== 11) {
        callback(new Error('请输入正确的手机号'))
    } else {
        callback()
    }
}
export default {
    name: "teacher",
    data() {
        return {
            ProductClassification: [],
            DomainClassification: [],
            props2: {
                lazy: true,
                lazyLoad: this.getLazyload2, // 领域分类
            },
            CPprops: {
                lazy: true,
                lazyLoad: this.getLazyload, // 产品分类
            },
            showvideo: true,
            ruleForm: {
                name: '',
                mobile: '',
                jobaddress: '',
                job: '',
                industry: '',
                instrument: '',
                inviter: '',
                abstr: ''
            },
            rules: {
                name: [
                    { required: true, message: '请输入姓名', trigger: 'blur' },
                ],
                mobile: [
                    { required: true, message: '请输入手机号', trigger: 'change' },

                    { validator: validateMobile.bind(this), trigger: 'blur' },
                ],
                jobaddress: [
                    { required: true, message: '请输入单位', trigger: 'blur' },
                ],
                job: [
                    { required: true, message: '请输入职位', trigger: 'blur' },
                ],
                industry: [
                    {required: true, message: '请选择熟悉行业', trigger: 'changeImIndustry' }
                ],
                instrument: [
                    { required: true, message: '请选择熟悉仪器', trigger: 'changeImmsort' }
                ],
            }
        };
    },
    mounted() {
        // 埋点
        // this.$sensors.registerPage({
        //   sensorsdata_platform_type: "PC",
        //   sensorsdata_column_name: "仪信通",
        // });
        // this.$sensors.track("sensorsdata_yixintong_event", {
        //   $screen_name: `PC-仪信通-厂商登录页`,
        //   $is_first_time: true,
        //   $url: window.location.href,
        //   $referrer: this.$sensors.getPresetProperties().$referrer,
        // });
        var sensorsdataModel= {
            sensorsdata_platform_type: "PC",
            sensorsdata_column_name: "3I讲堂",
            $screen_name: "PC-3i讲堂-讲师申请页",
            $is_first_time: true,
            $referrer: document.referrer
        }
        console.log("sensorsdataModel="+sensorsdataModel);
        sensors.track('sensorsdata_wangluojiangtang_event', sensorsdataModel);
    },
    methods: {
        changeImmsort(val) {
            this.ruleForm.level1IdYq = val[0];
            this.ruleForm.level2IdYq = val[1];
            this.ruleForm.level3IdYq = val[2];
            this.$nextTick(() => {
                let data = this.$refs["areaCascader"].getCheckedNodes(false);
                this.ruleForm.level1NameYq = data[0].pathLabels[0];
                this.ruleForm.level2NameYq = data[0].pathLabels[1];
                this.ruleForm.level3NameYq = data[0].pathLabels[2];
            });
            this.ruleForm.instrument =  val[2];
        },
        // 获取产品分类内容
        getLazyload(node, resolve) {
            if (!node) {
                return false;
            }
            const { level } = node;

            axios(
                `https://gateway.instrument.com.cn/classificationMonitoring/classify/getPrincipleClassifySelectByParentId?parentId=${level == 0 ? 0 : node.value
                }`,
                { headers: { "Content-type": "application/x-www-form-urlencoded" } }
            ).then((res) => {
                // 换成你的接口方法
                if (res.data.code == 1) {
                    resolve(
                        res.data.data.map((val) => {
                            return {
                                value: val.id,
                                label: val.name,
                                leaf: level >= 2, // 因为省市区三项，所以第三次点击就不用在加载了，所以 >=2
                            };
                        })
                    );
                }
            });
        },
        getLazyload2(node, resolve) {
            if (!node) {
                return false;
            }
            const { level } = node;
            axios(
                `https://gateway.instrument.com.cn/classificationMonitoring/classify/getIndustryClassifySelectByParentId?parentId=${level == 0 ? 0 : node.value
                }`,
                { headers: { "Content-type": "application/x-www-form-urlencoded" } }
            ).then((res) => {
                // 换成你的接口方法
                if (res.data.code == 1) {
                    resolve(
                        res.data.data.map((val) => {
                            return {
                                value: val.id,
                                label: val.name,
                                leaf: level >= 1, // 因为省市区三项，所以第三次点击就不用在加载了，所以 >=2
                            };
                        })
                    );
                }
            });
        },
        changeImIndustry(val) {
            this.ruleForm.level1IdHy = val[0];
            this.ruleForm.level2IdHy = val[1];
            this.$nextTick(() => {
                let data = this.$refs["areaCascader2"].getCheckedNodes(false);
                this.ruleForm.level1NameHy = data[0].pathLabels[0];
                this.ruleForm.level2NameHy = data[0].pathLabels[1];
            });
            this.ruleForm.industry =  val[1];
        },
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    api.login.saveWebinarBecomeAuthor(this.ruleForm).then((res) => {
                        if (res.code != 200) {
                            this.$message({
                                type: 'error',
                                message: '服务器异常，建议您直接拨打电话：4006-315-817'
                            })
                        } else {
                            this.$message({
                                type: 'success',
                                message: '提交成功，稍后会有工作人员与您联系！'
                            })
                        }
                    })
                    alert('submit!');
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        }

    },
};
</script>
<style lang="scss" scoped>
@import "@/styles/index.scss";

input[type="password"]::-ms-reveal {
    display: none; // 隐藏input type=password时，浏览器自带的小眼睛
}
.login-nav {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, .03);
    background: #fff;

    .nav-content {
      width: 1200px;
      height: 100%;
      margin: 0 auto;
      @include flex(row, center, space-between);

      .l-logo {
        a {
          height: 100%;
        //   display: inline-block;
          cursor: pointer;
          display: flex;
          align-items: center;
          &:first-child {
            width: 190px;
            // border-right: 1px solid #ccc;
            // padding-right: 16px;
          }
          &:last-child {
            width: 230px;
    padding-left: 100px;
    padding-top: 5px;
          }
          img {
            width: 155px;
          }
        }
        span{
            font-size: 18px;
    color: #000;
    font-weight: bold;
    padding-left: 12px;
    letter-spacing:2px;
        }
      }
      .r-menus {
        @include flex(row, center, flex-start);

        .title {
          font-size: 18px;
          color: #323233;
          margin: 0 14px;
          padding: 25px 6px 25px;
          position: relative;
          line-height: 1;

          &.active {
            color: #0C7FF2;

            &::after {
              content: "";
              position: absolute;
              height: 4px;
              background: #0C7FF2;
              bottom: 0px;
              left: 0;
              right: 0;
            }
          }
        }
        .meun-tel {
          width: 200px;
          // height: 45px;
          border: 1px solid #ebedf0;
          border-radius: 4px;
          padding: 5px 8px;
          margin-left: 30px;
          box-sizing: border-box;
          margin-right: 35px;
          @include flex(row, center, flex-start);

          .tel-icon {
            width: 34px;
            height: 34px;
            background: #0C7FF2;
            border-radius: 4px;
            margin-right: 12px;
            vertical-align: middle;
            text-align: center;
            line-height: 34px;
            font-size: 20px;
          }
          .tel-num {
            font-size: 18px;
            line-height: 1;
            color: #0C7FF2;
          }
        }
        .menu-btn {
          font-size: 18px;
          color: #fff;
          padding: 14px 40px;
          line-height: 1;
          border-radius: 6px;
          background: #0C7FF2;
          border: none;
          list-style: none;
          cursor: pointer;
          transition: 0.3s;

          &:hover {
            opacity: 0.8;
          }
        }
      }
    }
  }
.sign-container {
    width: 100%;
    min-width: 1200px;
    position: relative;
    background: url(https://img1.17img.cn/ui/simg/instrument/20230302/yht/img/bej_1x_20220302.png) no-repeat;
    background-size: cover;
    min-height: 100%;

    .sign-box {
        width: 1130px;
        padding: 5% 0;
        box-sizing: border-box;
        margin: 0 auto;
        @include flex(row, flex-start, space-between);

        .sign-bg {
            width: 45%;

            .sign-bg-title {
                font-size: 50px;
                letter-spacing: 8.5px;
                font-family: PingFang SC-Semibold, PingFang SC;
                font-weight: 600;
                color: #000000;
                line-height: 59px;
                margin-bottom: 6px;
                margin-left: -5px;
            }

            .sign-bg-t-gary {
                font-size: 20px;
                font-family: PingFang SC-Regular, PingFang SC;
                font-weight: 400;
                line-height: 23px;
                letter-spacing: 9px;
                color: #a7b0c4;
                margin-bottom: 30px;
            }

            .sign-bg-begin {
                font-size: 24px;
                color: #4f5862;
                line-height: 28px;
                margin-bottom: 27px;
                letter-spacing: 5px;
            }

            img {
                width: 100%;
            }
        }

        .sign-form {
            width: 578px;
            height: 700px;
            // margin-top: 64px;
            background-color: #fff;
            box-shadow: 0px 0px 4px 4px rgba(0, 0, 0, 0.05);
            padding: 40px 40px 40px;
            box-sizing: border-box;
            position: relative;

            .account-tab {
                position: absolute;
                left: 0;
                right: 0;
                top: 0;
                height: 72px;

                span {
                    font-size: 14px;
                    color: #ff6332;
                    padding: 7px 12px;
                    background: #fff4f0;
                    display: inline-block;
                    border: 1px solid #ff6332;
                    border-radius: 4px;
                    margin-top: 21px;
                    margin-left: 273px;
                    position: relative;

                    &::after {
                        content: "";
                        width: 10px;
                        height: 10px;
                        border: 1px solid #ff6332;
                        border-radius: 2px;
                        border-left: none;
                        border-bottom: none;
                        position: absolute;
                        right: -6px;
                        top: 9px;
                        margin-right: 0px;
                        margin-bottom: 0px;
                        background: #fff4f0;
                        transform: rotate(45deg);
                    }
                }

                img {
                    position: absolute;
                    top: 0;
                    right: 0;
                    width: 72px;
                    height: 72px;
                    cursor: pointer;
                }
            }

            .title {
                font-size: 24px;
                font-family: PingFang SC, PingFang SC;
                font-weight: 600;
                color: #202933;
                line-height: 28px;
                text-align: center;
                margin-bottom: 7px;
            }

            .ms {
                font-size: 14px;
                font-family: PingFang SC, PingFang SC;
                font-weight: 400;
                color: #7E8790;
                line-height: 16px;
                text-align: center;
                margin-bottom: 35px;
            }

            ::v-deep .input-code input {
                width: 100%;
                position: relative;
                background: #f7f8fa;
                list-style: none;
                border: none;
                outline: none;
                color: #000;
                margin-left: 5px;

                ::-webkit-input-placeholder,
                ::-moz-placeholder,
                -ms-input-placeholder {
                    color: #b9c0c7;
                }
            }

            ::v-deep .input-code textarea {
                width: 100%;
                position: relative;
                background: #f7f8fa;
                list-style: none;
                border: none;
                outline: none;
                color: #000;
                margin-left: 5px;

                ::-webkit-input-placeholder,
                ::-moz-placeholder,
                -ms-input-placeholder {
                    color: #b9c0c7;
                }
            }

            .teache-butn {
                width: 330px !important;
                margin-left: 7px !important;
                height: 26px !important;
            }

            .el-form-item {
                margin-bottom: 20px;
            }

            .form-title {
                width: 100%;
                margin-bottom: 45px;

                a {
                    display: inline-block;
                    padding-bottom: 14px;
                    margin-right: 40px;
                    font-size: 24px;
                    color: #7e8790;
                    position: relative;
                    font-weight: bold;

                    &.active {
                        color: #000;

                        &::after {
                            content: "";
                            width: 100%;
                            height: 4px;
                            background: #0c7ff2;
                            position: absolute;
                            left: 0;
                            right: 0;
                            bottom: 0;
                        }
                    }
                }
            }

            .form-box {
                width: 400px;

                .box-input {
                    width: 100%;
                    height: 54px;
                    background: #f7f8fa;
                    border: 1px solid #f7f8fa;
                    margin-bottom: 32px;
                    padding: 18px 24px 18px 12px;
                    box-sizing: border-box;
                    position: relative;
                    @include flex(row, center, space-between);

                    input {

                        &:-webkit-autofill,
                        &:-webkit-autofill:hover,
                        &:-webkit-autofill:focus,
                        &:-webkit-autofill:active {
                            -webkit-box-shadow: 0 0 0 1000px #f7f8fa inset !important;
                        }
                    }

                    &.error {
                        border: 1px solid #e53917;

                        .error-tip {
                            position: absolute;
                            bottom: -25px;
                            left: 0;
                            font-size: 12px;
                            color: #e53917;

                            &>a {
                                font-size: 12px;
                                color: #4f5862;
                                text-decoration: underline;
                            }
                        }
                    }

                    .input-num {
                        font-size: 16px;
                        color: #000;
                        margin-right: 18px;
                        line-height: 1;
                    }

                    &::v-deep .vue-country-intl {
                        width: 50px;
                        font-size: 16px;
                        color: #000;
                        line-height: 1;

                        .vue-country-list-wrap {
                            width: 500px;
                        }

                        .country-intl-input-wrap {
                            border: none;
                            border-radius: 0;

                            .dropdown-flag {
                                display: none;
                            }

                            .country-intl-input {
                                padding: 0;
                                height: auto;
                                background: #f7f8fa;
                            }

                            .country-intl-label {
                                padding: 0;
                                background: transparent;
                                height: inherit;
                                line-height: 1;
                                font-size: 16px;
                            }
                        }
                    }

                    .line {
                        width: 1px;
                        height: 18px;
                        display: inline-block;
                        vertical-align: middle;
                        background-color: rgba(185, 192, 199, 0.4);
                    }

                    .input-tel {
                        width: 87%;
                        padding-left: 15px;
                        position: relative;
                        background: #f7f8fa;
                        list-style: none;
                        border: none;
                        outline: none;
                        color: #000;

                        &.account {
                            padding-left: 0;
                        }

                        ::-webkit-input-placeholder,
                        ::-moz-placeholder,
                        -ms-input-placeholder {
                            color: #b9c0c7;
                        }
                    }

                    .input-code {
                        width: 66%;
                        position: relative;
                        background: #f7f8fa;
                        list-style: none;
                        border: none;
                        outline: none;
                        color: #000;
                        margin-left: 5px;

                        ::-webkit-input-placeholder,
                        ::-moz-placeholder,
                        -ms-input-placeholder {
                            color: #b9c0c7;
                        }
                    }

                    .input-send {
                        width: 33%;
                        color: #74808b;
                        font-size: 16px;
                        cursor: pointer;
                        display: block;
                        text-align: right;

                        &.higt {
                            color: #74808b;
                        }

                        &.count {
                            cursor: inherit;
                        }

                        &:hover {
                            opacity: 0.8;
                        }
                    }
                }

                .box-read {
                    width: 100%;
                    height: 20px;
                    color: #7e8790;
                    font-size: 16px;
                    margin: 20px 0;
                    @include flex(row, center, flex-end);

                    a {
                        transition: 0.3s;

                        &:hover {
                            opacity: 0.8;
                        }
                    }
                }

                .box-btn {
                    width: 100%;
                    padding: 16px 0 !important;
                    background: #1e84fc;
                    font-size: 18px;
                    color: #ffffff;
                    line-height: 1;
                    margin-bottom: 32px;
                    border: none;
                    border-radius: 4px;
                    cursor: pointer;
                    transition: 0.2s;

                    &:hover {
                        opacity: 0.8;
                    }
                }

                .box-register {
                    width: 80px;
                    display: block;
                    margin: 0 auto;
                    font-size: 16px;
                    color: #0c7ff2;
                    text-align: center;
                    transition: 0.2s;

                    &:hover {
                        opacity: 0.8;
                    }
                }
            }
        }

        .code-form {
            width: 480px;
            height: 510px;
            margin-top: 28px;
            background-color: #fff;
            box-shadow: 0px 0px 4px 4px rgba(0, 0, 0, 0.05);
            padding: 73px 40px 40px;
            box-sizing: border-box;
            position: relative;

            .account-tab {
                position: absolute;
                left: 0;
                right: 0;
                top: 0;
                height: 72px;

                span {
                    font-size: 14px;
                    color: #ff6332;
                    padding: 7px 12px;
                    background: #fff4f0;
                    display: inline-block;
                    border: 1px solid #ff6332;
                    border-radius: 4px;
                    margin-top: 21px;
                    margin-left: 273px;
                    position: relative;

                    &::after {
                        content: "";
                        width: 10px;
                        height: 10px;
                        border: 1px solid #ff6332;
                        border-radius: 2px;
                        border-left: none;
                        border-bottom: none;
                        position: absolute;
                        right: -6px;
                        top: 9px;
                        margin-right: 0px;
                        margin-bottom: 0px;
                        background: #fff4f0;
                        transform: rotate(45deg);
                    }
                }

                img {
                    position: absolute;
                    top: 0;
                    right: 0;
                    width: 72px;
                    height: 72px;
                    cursor: pointer;
                }
            }

            .code-title {
                font-size: 24px;
                text-align: center;
                color: #202933;
                margin: 35px auto 20px;
                font-weight: bold;
            }

            .code-box {
                width: 208px;
                margin: 0 auto;
                position: relative;

                img {
                    width: 208px;
                    height: 208px;
                    margin-bottom: 40px;
                }

                .code-invalid {
                    width: 208px;
                    height: 208px;
                    background: rgba(0, 0, 0, 0.7);
                    position: absolute;
                    left: 0;
                    top: 0;
                    z-index: 9;

                    .invalid-title {
                        font-size: 14px;
                        color: #fff;
                        display: block;
                        font-weight: 400;
                        margin: 80px auto 20px;
                        text-align: center;
                    }

                    .invalid-btn {
                        display: block;
                        margin: 0 auto;
                        background: #ff6332;
                        font-size: 18px;
                        font-weight: 400;
                        border: 1px solid #ff6332;
                        padding: 5px 16px;

                        &:hover {
                            opacity: 0.9;
                        }
                    }
                }

                p {
                    width: 100%;
                    text-align: center;
                    font-size: 16px;
                    color: #4f5862;
                    line-height: 1.5;

                    a {
                        color: #ff6332;
                    }
                }
            }

            .code-confirm-ing {
                width: 208px;
                margin: 0 auto;
                text-align: center;
                position: relative;

                .confirm-sao-icon {
                    font-size: 100px;
                    color: #ff6332;
                    margin: 38px auto;
                }

                .confirm-succ {
                    font-size: 20px;
                    color: #4f5862;
                    font-weight: 500;
                    line-height: 1;
                    margin: 15px auto;
                    text-align: center;
                }

                .confirm-succ-gary {
                    font-size: 16px;
                    color: #7e8790;
                    line-height: 1;
                    font-weight: 400;
                    margin: 15px auto 55px;
                    text-align: center;
                }

                .confirm-succ-back {
                    font-size: 16px;
                    color: #ff6332;
                    line-height: 1;
                    font-weight: 400;
                    margin: 55px auto 0;
                    text-align: center;
                    cursor: pointer;
                    transition: 0.3s;

                    &:hover {
                        opacity: 0.8;
                    }
                }
            }
        }
    }
}
</style>
  